#!/bin/bash
# 工作目录
WORK_DIR=$(pwd)
# 语言环境设置为UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
# 区分日志级别颜色
SET_COLOR_TIPS="\033[1;36m"
SET_COLOR_NORMAL=" \033[0;39m"
SET_COLOR_SUCCESS="\033[1;32m"
SET_COLOR_WARNING="\033[1;33m"
SET_COLOR_FAILURE="\033[1;31m"

# 定义记录日志的函数
function LogTipMsg() {
    time=$(date "+%Y/%m/%d %T")
    printf "%b[%s] [STEP] %s%b\n" "$SET_COLOR_TIPS" "$time" "$*" "$SET_COLOR_NORMAL"
}

function LogInfoMsg() {
    time=$(date "+%Y/%m/%d %T")
    printf "[%s] [INFO] %s%b\n" "$time" "$*" "$SET_COLOR_NORMAL"
}

function LogSucMsg() {
    time=$(date "+%Y/%m/%d %T")
    printf "%b[%s] [SUC.] %s%b\n" "$SET_COLOR_SUCCESS" "$time" "$*" "$SET_COLOR_NORMAL"
}

function LogWarnMsg() {
    time=$(date "+%Y/%m/%d %T")
    printf "%b[%s] [WARN] %s%b\n" "$SET_COLOR_WARNING" "$time" "$*" "$SET_COLOR_NORMAL"
}

function LogErrorMsg() {
    time=$(date "+%Y/%m/%d %T")
    printf "%b[%s] [ERR.] %s%b\n" "$SET_COLOR_FAILURE" "$time" "$*" "$SET_COLOR_NORMAL"
}

function updateHistorySiteData() {
    # 备份历史数据
    cp data/historySiteList.json data/historySiteList.bak
    # 从构建输出中提取历史数据
    cp docs/site-list.json data/historySiteList.json
    LogSucMsg "历史站点数据文件已更新"
#    git add data/historySiteList.json
#    git commit -m "更新历史站点数据"
}

updateHistorySiteData